from predigit import showdigit,DIGITS
from mlp import MLP1,MLP2,plot_learning_curve



m1 = MLP1(10000,2000)
m1.train((20))
m1.test()
print("+++++++++++++++++++++++++++++++++++++++++++")
print("+++++++++++++++++++++++++++++++++++++++++++")
m2 =MLP2(10000,2000)
m2.train((10,402))
m2.test()
#m1.learning_curve()
#plot_learning_curve(m1)
#m2.learning_curve()
#plot_learning_curve(m2)
digits = DIGITS()
#datatr,datate = digits.getSimpleData()
datatr = digits.getImgsSet()
datate = digits.getImgsSet(True)

#test data in test
def predict(m,i1):
    showdigit(datate[i1])
    m.M.predict(datate[i1:i1+1])

def gettrainlog(f):
    f =  open(f,"r")
    line =  f.readline()
    while True:
        if "loss" in line:
            line = line.strip()
            r = line.split(',')
            line = f.readline()
            line = line.strip()
            print(r[0].split(' ')[1],r[1].split('= ')[1],line.split(": ")[1])

            line = f.readline()
            if 'test_score' in line:
                break;
        else:
            break;
#gettrainlog("res/mlp1train.log")
#gettrainlog("res/mlp2train.log")